local sk__yidu = fk.CreateSkill {

  name = "sk__yidu",

  tags = {  },

}



sk__yidu:addEffect(fk.AfterCardsMove, {
  name = "sk__yidu",
  anim_type = "drawcard",
  can_trigger = function(self, event, target, player, data)
    if player:hasSkill(sk__yidu.name) and player.phase == Player.NotActive and player:usedSkillTimes(sk__yidu.name, Player.HistoryTurn) == 0 and
      player.room.current and not player.room.current.dead and not player.room.current:isKongcheng() then
      for _, move in ipairs(data) do
        if move.from and move.from == player then
          for _, info in ipairs(move.moveInfo) do
            if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
              if table.find(player.room.current:getCardIds("h"), function(id)
                return Fk:getCardById(id).suit == Fk:getCardById(info.cardId).suit and
                  Fk:getCardById(info.cardId).suit ~= Card.NoSuit
                end) then
                return true
              end
            end
          end
        end
      end
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    local suits = {}
    for _, move in ipairs(data) do
      if move.from and move.from == player then
        for _, info in ipairs(move.moveInfo) do
          if info.fromArea == Card.PlayerHand or info.fromArea == Card.PlayerEquip then
            if Fk:getCardById(info.cardId).suit ~= Card.NoSuit then
              table.insertIfNeed(suits, Fk:getCardById(info.cardId).suit)
            end
          end
        end
      end
    end
    local n = 0
    for _, id in ipairs(room.current:getCardIds("h")) do
      if table.contains(suits, Fk:getCardById(id).suit) then
        n = n + 1
      end
    end
    player:drawCards(n, sk__yidu.name)
  end,
})

return sk__yidu